# -*- coding: utf-8 -*-
"""
@Time ： 2023/9/14 9:55
@Auth ： y.h
@File ：sort_util.py
@IDE ：PyCharm
@Motto：The sooner you start to code, the longer the program will take. —— Roy Carlson
"""


__all__ = ["sort_util"]


def sort_util(data_list: list, index: int, is_revers: bool = False) -> list:
    """
    列表排序工具
    :param data_list:源数据列表
    :type data_list:list
    :param is_revers:是否反转
    :type is_revers:bool
    :param index:排序key索引
    :type index:int
    :return:排序完成后的列表
    :rtype:list
    """
    data_list = sorted(data_list, key=lambda element: element[index], reverse=is_revers)
    return data_list


def aa_test_00():
    data_lst = [[1, 2], [3, 4], [5, 6], [2, 1]]
    data = sort_util(data_lst, True, 0)
    print(data)


if __name__ == '__main__':
    aa_test_00()
